# 极值常量
# 最大值
MAX_VALUE = "max_value"
# 最小值
MIN_VALUE = "min_value"


# 获取数组最小值
def get_array_max_value(array):
    return get_array_extreme_value(array, MAX_VALUE)


# 获取数组最大值
def get_array_min_value(array):
    return get_array_extreme_value(array, MIN_VALUE)


# 获取数组极值
def get_array_extreme_value(array, extreme_type=MAX_VALUE):
    if array is None or len(array) <= 1:
        raise ValueError("传递数组不合规范")
    array_len = len(array)
    # 定义初始极值
    extreme_value = array[0]
    # 获取最大值
    if MAX_VALUE.__eq__(extreme_type):
        for i in range(0, array_len):
            if array[i] > extreme_value:
                extreme_value = array[i]
    # 获取最小值
    if MIN_VALUE.__eq__(extreme_type):
        for i in range(0, array_len):
            if array[i] < extreme_value:
                extreme_value = array[i]
    return extreme_value
